{extend name="base"/}
{block name="resources"}
<style>
	.ns-shop-detail p {
		display: inline-block;
		width: 300px;
		line-height: 30px;
	}
    .ns-card-brief:nth-child(1){
        margin-top: 0;
    }
    .layui-card-body{
        display: flex;
        flex-wrap: wrap;
        padding-bottom: 0 !important;
        padding-left: 50px !important;
        padding-right: 50px !important;
    }
    .layui-card-body .content{
        width: 25%;
        margin-bottom: 30px;
        display: flex;
        flex-wrap: wrap;
        flex-direction: column;
        justify-content: center;
    }
    .layui-card-body .money{
        font-size: 20px;
        color: #000;
        font-weight: bold;
        margin-top: 10px;
        max-width: 250px;
    }
    .layui-card-body .subhead{
        font-size: 12px;
        margin-left: 3px;
        cursor: pointer;
    }
</style>
{/block}
{block name="main"}
<div class="layui-collapse ns-tips">
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">操作提示</h2>
        <ul class="layui-colla-content layui-show">
            <li>店铺收入金额 = 店铺结算总金额 - 店铺退款金额 - 佣金金额</li>
            <li>平台抽成金额 = 平台结算总抽成 - 平台退款抽成</li>
        </ul>
    </div>
</div>

<div class="ns-detail-card ns-tips">
	<div class="ns-detail-con">
		<p class="ns-detail-line">
			<span class="ns-goods-name">店铺名称：{$shop_info.site_name}</span>
		</p>
	</div>
</div>

<div class="layui-card ns-card-common ns-card-brief">
    <div class="layui-card-header">
        <div>
            <span class="ns-card-title">店铺结算</span>
            <span>账期时间：{:date('Y-m-d H:i:s', $info.period_start_time)} 至 {:date('Y-m-d H:i:s', $info.period_end_time)}</span>
        </div>
    </div>
    <div class="layui-card-body">
        <div class="content">
            <p class="title">店铺结算总金额（元）</p>
            <p class="money">{$info.shop_money}</p>
        </div>
        <div class="content">
            <p class="title">店铺退款金额（元）</p>
            <p class="money">{$info.refund_shop_money}</p>
        </div>
        <div class="content">
            <p class="title">店铺收入金额（元）</p>
            <p class="money">{$shop_money}</p>
        </div>
        <div class="content">
            <p class="title">佣金金额（元）</p>
            <p class="money">{$info.commission}</p>
        </div>
        <div class="content">
            <p class="title">平台抽成金额（元）</p>
            <p class="money">{$money}</p>
        </div>
        <div class="content">
            <p class="title">平台结算总抽成（元）</p>
            <p class="money">{$info.platform_money}</p>
        </div>
        <div class="content">
            <p class="title">平台退款抽成（元）</p>
            <p class="money">{$info.refund_platform_money}</p>
        </div>
    </div>
</div>



<!-- 搜索框 -->
<div class="ns-single-filter-box">
    <div class="layui-form">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" placeholder="开始时间" name="start_date" id="start_time" autocomplete="off" readonly>
                </div>
                <div class="layui-input-inline end-item">
                    <input type="text" class="layui-input" placeholder="结束时间" name="end_date" id="end_time" autocomplete="off" readonly>
                </div>
            </div>
        </div>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>
                <i class="layui-icon">&#xe615;</i>
            </button>
        </div>
        <input type="hidden" name="settlement_id" id="settlement_id" value="{$settlement_id}" />
    </div>
</div>
<!-- 列表 -->
<table id="order_list" lay-filter="order_list"></table>

<!--时间-->
<script type="text/html" id="times">
    <div class="layui-elip">{{ns.time_to_date(d.finish_time)}}</div>
</script>

<!--店铺金额-->
<script type="text/html" id="shop_money">
    <div class="layui-elip" style="color:green;">￥{{d.shop_money}}</div>
</script>

<!--平台抽成-->
<script type="text/html" id="platform_money">
    <div class="layui-elip" style="color: red;">￥{{d.platform_money}}</div>
</script>
{/block}

{block name="script"}
<script>
    layui.use(['form', 'laydate'], function() {
        var table,
            form = layui.form,
            laydate = layui.laydate,
            currentDate = new Date(),
            minDate = "";
        var settlement_id = $("#settlement_id").val();
        form.render();

        currentDate.setDate(currentDate.getDate() - 7);

        //开始时间
        laydate.render({
            elem: '#start_time',
            type: 'datetime'
        });

        //结束时间
        laydate.render({
            elem: '#end_time',
            type: 'datetime'
        });
        
        /**
         * 重新渲染结束时间
         */
        function reRender(){
            $("#end_time").remove();
            $(".end-time").html('<input type="text" class="layui-input" placeholder="结束时间" name="end_date" id="end_time" >');
            laydate.render({
                elem: '#end_time',
                type: 'datetime',
                min: minDate
            });
        }

        /**
         * 表格加载
         */
        table = new Table({
            elem: '#order_list',
            url: ns.url("admin/shopsettlement/shopdetail"),
            where: {'settlement_id': settlement_id},
            cols: [
                [{
                    field: 'site_name',
                    title: '店铺',
                    width: '12%',
                    unresize: 'false',
                }, {
                    field: 'order_no',
                    title: '订单号',
                    width: '12%',
                    unresize: 'false'
                },{
                    field: 'order_money',
                    title: '订单总金额',
                    width: '12%',
                    unresize: 'false',
					align: 'right',
					templet: function(data) {
						return '￥'+ data.order_money;
					}
                }, {
                    field: 'shop_money',
                    title: '店铺退款金额',
                    width: '12%',
                    unresize: 'false',
                    align: 'right',
                    templet: function(data) {
                        return '￥'+ data.refund_shop_money;
                    }
                }, {
                    field: 'shop_money',
                    title: '平台退款金额',
                    width: '12%',
                    unresize: 'false',
                    align: 'right',
                    templet: function(data) {
                        return '￥'+ data.refund_platform_money;
                    }
                }, {
                    field: 'shop_money',
                    title: '店铺金额',
                    width: '12%',
                    unresize: 'false',
					align: 'right',
					templet: function(data) {
						return '￥'+ ns.int_to_float(data.shop_money - data.refund_shop_money - data.platform_money);
					}
                }, {
                    field: 'platform_money',
                    title: '<span style="padding-right: 50px;">平台抽成</span>',
                    width: '13%',
                    unresize: 'false',
					align: 'right',
					templet: function(data) {
						return '<span style="padding-right: 50px;">￥'+ data.platform_money +'</span>';
					}
                }, {
                    title: '完成时间',
                    width: '12%',
                    unresize: 'false',
                    templet: '#times'
                }]
            ]
        });

        /**
         * 搜索功能
         */
        form.on('submit(search)', function(data) {
            table.reload({
                page: {
                    curr: 1
                },
                where: data.field
            });
        });
    });
</script>
{/block}